package com.squid.base.config.mybatis.interceptor;

import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
import com.baomidou.mybatisplus.core.MybatisConfiguration;
import jakarta.annotation.Resource;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(MybatisIgnoreProperties.class)
public class MybatisInterceptor implements ConfigurationCustomizer {
    @Resource
    private MybatisIgnoreProperties mybatisIgnoreProperties;

    @Override
    public void customize(MybatisConfiguration configuration) {
        if (mybatisIgnoreProperties.getEnableSlowQueryNotify()) {
            configuration.addInterceptor(new SlowSqlNotifyMybatisInterceptor(mybatisIgnoreProperties));
        }
    }

}
